# -*- coding: utf-8 -*-
from win32com.client import Dispatch

oConnA = Dispatch('ADODB.Connection')
oConnA.ConnectionString = r"PROVIDER=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=data.accdb;Jet OLEDB:Database Password=tp@chenkai;"
oConnA.Open()
# oRSA = Dispatch('ADODB.RecordSet')
oCmdA = Dispatch('ADODB.Command')
oCmdA.ActiveConnection = oConnA

# oRSA.Open("select cd_no from cd where cd_no in ("+cdnos_str+")",oConnA,1,1)


oConn = Dispatch('ADODB.Connection')
oConn.ConnectionString = r'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=top.xls;Extended Properties="Excel 8.0;HDR=Yes;IMEX=1";'
oConn.Open()
oRS = Dispatch('ADODB.RecordSet')
oRS.Open(r"select ddid,x,d from [Sheet2$]",oConn,1,3)
while not oRS.EOF:
	ddid=str(int(oRS.Fields("ddid").Value))
	x=str(int(oRS.Fields("x").Value))
	d=str(int(oRS.Fields("d").Value))
	print ddid,x,d
	oCmdA.CommandText = "insert into RateTemp(PlaceID,BoxID,Price) values("+ddid+",1,"+x+")"
	print oCmdA.CommandText
	
	# oCmdA.Execute()
	oCmdA.CommandText = "insert into RateTemp(PlaceID,BoxID,Price) values("+ddid+",2,"+d+")"
	print oCmdA.CommandText
	# oCmdA.Execute()
	oRS.MoveNext()
oRS.Close()
oRS=None
oConn.Close()
oConn=None

oCmdA=None
oConnA.Close()
oConnA=None




	
